package com.dw.user.controller;



import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dw.common.entitys.BaseResponse;
import com.dw.common.utils.ResultUtils;
import com.dw.model.user.dtos.AddUserFollowDTO;
import com.dw.model.user.entitys.UserFollow;
import com.dw.model.user.entitys.UserInfo;
import com.dw.model.user.vos.GetUserVO;
import com.dw.user.service.UserFollowService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.io.Serializable;
import java.util.List;

/**
 * 用户关注表(UserFollow)表控制层
 *
 * @author makejava
 * @since 2024-10-17 09:16:00
 */
@Slf4j
@RestController
@RequestMapping("/user")
public class UserFollowController {

    @Resource
    private UserFollowService userFollowService;

    /**
     * 关注
     */
    @PostMapping("/follow")
    public BaseResponse<Boolean> follow(@RequestBody AddUserFollowDTO addUserFollowDTO) {
        log.info("用户关注传参:{}", addUserFollowDTO);
        userFollowService.follow(addUserFollowDTO);
        return ResultUtils.success(true);
    }

    /**
     * 查询是否关注
     */
    @GetMapping("/isFollow")
    public BaseResponse<Boolean> isFollow(@RequestParam("userId") Long userId,@RequestParam("followId") Long followId) {
        log.info("查询是否关注传参:{}", followId);
        Boolean result = userFollowService.isFollow(userId,followId);
        return ResultUtils.success(result);
    }

    /**
     * 查询用户关注的用户列表
     */
    @GetMapping("/getAllFollow")
    public BaseResponse<List<GetUserVO>> getAllFollow(@RequestParam("userId") Long userId) {
        log.info("查询用户关注的用户列表传参:{}", userId);
        return ResultUtils.success(userFollowService.getAllFollow(userId));
    }

    /**
     * 查询用户的粉丝列表
     */
    @GetMapping("/getAllFans")
    public BaseResponse<List<GetUserVO>> getAllFans(@RequestParam("userId") Long userId) {
        log.info("查询用户的粉丝列表传参:{}", userId);
        return ResultUtils.success(userFollowService.getAllFans(userId));
    }

}

